package com.jiutong.meipengdai.ui.activitys;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.jiutong.meipengdai.R;
import com.jiutong.meipengdai.base.BaseActivity;
import com.jiutong.meipengdai.entity.MsgCenterRespond;
import com.jiutong.meipengdai.http.model.interfaces.CheckLoginInterface;
import com.jiutong.meipengdai.http.model.interfaces.MyAccountBiz;
import com.jiutong.meipengdai.http.present.MyAccountPresent;
import com.jiutong.meipengdai.ui.adapter.MsgAdapter;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 消息中心
 * Created by suxi on 2017/6/2.
 */
@CheckLoginInterface
public class MsgCenterActivity extends BaseActivity implements View.OnClickListener, MyAccountBiz {

    @Bind(R.id.tv_title)
    TextView tv_title;
    @Bind(R.id.rl_back)
    RelativeLayout rl_back;
    @Bind(R.id.msg_recyclerview)
    RecyclerView msg_recyclerview;
    @Bind(R.id.tv_no_date)
    TextView tvNoDate;

    private List<MsgCenterRespond.DataBean.MessagesBean> messages;


    @Override
    public int getLayoutResouceId() {
        return R.layout.activity_msg_center;
    }

    @Override
    protected void initDate(Bundle savedInstanceState) {
        super.initDate(savedInstanceState);
        MyAccountPresent present = new MyAccountPresent(this, this);
        present.getMsgCenter();
    }

    @Override
    protected void initView() {
        super.initView();
        ButterKnife.bind(this);
        tv_title.setText("我的消息");
    }

    @OnClick(R.id.iv_back)
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_back:
                finish();
                break;
        }
    }

    @Override
    public void onSuccess(Object object) {
        MsgCenterRespond respond = (MsgCenterRespond) object;
        if("200".equals(respond.getResCode()) && respond.getData().getMessages() != null && respond.getData().getMessages().size()>0){
            tvNoDate.setVisibility(View.GONE);
            messages = respond.getData().getMessages();
            LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext);
            linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
            msg_recyclerview.setLayoutManager(linearLayoutManager);
            MsgAdapter adapter = new MsgAdapter(mContext, messages);
            msg_recyclerview.setAdapter(adapter);
        }else{
            tvNoDate.setVisibility(View.VISIBLE);
        }

    }

    @Override
    public void onError(Throwable e) {

    }

    @Override
    public String getBankNum() {
        return null;
    }

    @Override
    public String getBankName() {
        return null;
    }

    @Override
    public String getCartStatus() {
        return null;
    }

    @Override
    public String getBankId() {
        return null;
    }

    @Override
    public String getMsgId() {
        return null;
    }

    @Override
    public String getLoanId() {
        return null;
    }

    @Override
    public String Consignee() {
        return null;
    }

    @Override
    public String getTelephone() {
        return null;
    }

    @Override
    public String getBigLocation() {
        return null;
    }

    @Override
    public String getDetail() {
        return null;
    }

    @Override
    public String getIsDefault() {
        return null;
    }

    @Override
    public String getOprType() {
        return null;
    }

    @Override
    public String getMainId() {
        return null;
    }
}
